//泛型
function login(username:string):string{
    return "okk"
}

function login_T<T>(username:T):T{
    return username
}

let res=login_T("黄紫红")
console.log(res)

function ypr<F,J,Y>(psd:F,kind:J,height:Y):[F,J,Y]{
    return [psd,kind,height]
}

let res_ypr=ypr(123,"荔枝",188)
console.log(res_ypr)

function hair<T extends string>(hair_color:T):T{
    return hair_color
}

let res_hair=hair("深棕")//字面量类型
console.log(res_hair)

type myType="manymany"|number//定义一个类型
function test<T extends myType>(eyes:T):T{
    return eyes
}let res_eyes=test("manymany")
console.log("黄紫红有"+res_eyes+"个眼睛")

type yprType = {name:string,age:number}
let brown : yprType ={
    name:"黄紫红",
    age:19
}
type brownType = keyof yprType
console.log()

function new_brown<T extends brownType>(age:T){
    return age
}
let resAge=new_brown("age")

function tired(wow,yep){
    return wow[yep]
}

let res_t=tired({name:"超级无敌旋风陀螺制霸天才酷拽炸上天黄紫红",age:199},"name")
console.log(res_t)

function tired2<T,I extends keyof T>(obj:T,omg:I){
    return obj[omg]
}
let res_i=tired2("!居然是黄紫红我们有救了！","length")
console.log(res_i)

let oi={
    length:18,
    oioi:()=>{
        console.log("oi想过年")
        return "OIoioioioioioi"
    }
}
console.log(oi.oioi)